import { ReactNode, lazy } from "react"
// import Friend from "../pages/Friend"
// import Mine from "../pages/Mine"
// import Page404 from "../pages/Page404"
// import Discover from "../pages/Discover"
// import Playlist from "../pages/Discover/Playlist"
// import Toplist from "../pages/Discover/Toplist"
// import Login from "../pages/Login"

//懒加载/动态组件

let Login = lazy<any>(() => new Promise((resolve) => {
    setTimeout(() => {
        resolve(import(/*webpackChunkName:'login'*/"../pages/Login"))
    }, 3000)
}))
let Mine = lazy(() => import(/*webpackChunkName:'mine'*/"../pages/Mine"))
let Page404 = lazy(() => import(/*webpackChunkName:'404'*/"../pages/Page404"))
let Friend = lazy(() => import(/*webpackChunkName:'friend'*/"../pages/Friend"))
let Discover = lazy(() => import(/*webpackChunkName:'discover'*/"../pages/Discover"))
let Playlist = lazy(() => import(/*webpackChunkName:'playlist'*/"../pages/Discover/Playlist"))
let Toplist = lazy(() => import(/*webpackChunkName:'toplist'*/"../pages/Discover/Toplist"))

//类型声明
export type Iroutes = Array<{
    path: string,
    element: ReactNode,
    children?: Iroutes,
    [k: string]: any
}>

let routes: Iroutes = [
    {
        path: "/login",
        element: <Login />
    },
    {
        path: "/friend/:name",
        element: <Friend />
    },
    {
        path: "/mine",
        element: <Mine />
    },
    {
        path: "*",
        element: <Page404 />
    },
    {
        path: "/discover",
        element: <Discover />,
        children: [
            {
                path: "playlist",
                element: <Playlist />
            },
            {
                path: "toplist",
                element: <Toplist />
            }
        ]
    }
]


export default routes